package com.david.IfaceAutoTest.controller;

import com.david.IfaceAutoTest.entity.InterfaceBody;
import com.david.IfaceAutoTest.service.InterfaceBodyService;
import io.swagger.annotations.*;
import com.david.IfaceAutoTest.entity.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *接口interface_body 控制层
 *
 * @author david
 * @since 2021-12-24
 */
@RestController
@Api(tags = "interface_body接口")
@RequestMapping("/IfaceAutoTest/interface-body")
public class InterfaceBodyController {

    private final InterfaceBodyService interfacebodyservice;

    @Autowired
    public InterfaceBodyController(InterfaceBodyService interfacebodyservice) {
        this.interfacebodyservice = interfacebodyservice;
    }

    @GetMapping("/list")
    @ApiOperation(value = "接口interface_body列表查询", notes = "list")
    public CommonResult<Object> list() {
        return CommonResult.success(interfacebodyservice.list());
    }

    @GetMapping("/get")
    @ApiOperation(value = "接口interface_body详情查询", notes = "get")
    public CommonResult<Object> get(Integer id) {
        return CommonResult.success(interfacebodyservice.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "接口interface_body保存", notes = "save")
    public CommonResult<Object> save(InterfaceBody interfacebody) {
        return CommonResult.success(interfacebodyservice.save(interfacebody));
    }

    @DeleteMapping("/delete")
    @ApiOperation(value = "接口interface_body删除", notes = "delete")
    public CommonResult<Object> delete(Integer id) {
        interfacebodyservice.removeById(id);
        return CommonResult.success();
    }
}
